package reno.eureka.timecycle.entity;

public class EarthExplainMO {

    /**
     * 时间处理逻辑
     * <p>
     * 地球时间固定循环
     * 美东夏令时间0点开始，每4小时转换一次，每24小时经历三个日夜
     * 起止时间（美东处于夏令时间时）	游戏中地球昼夜
     * 0:00-4:00	    昼
     * 4:00-8:00	    夜
     * 8:00-12:00	    昼
     * 12:00-16:00	    夜
     * 16:00-20:00	    昼
     * 20:00-次日0:00	夜
     */

    public EarthExplainMO(CycleMO cycleMO) {
        long timeCurr = System.currentTimeMillis();
        long timeTarget = 1547352000000L;
        long timeResult = (timeCurr - timeTarget) / 1000 % 28800;
        long time;
        if (timeResult >= 14400) {
            currval = "夜晚";
            nextval = "白天";
            time = 28800 - timeResult;
        } else {
            currval = "白天";
            nextval = "夜晚";
            time = 14400 - timeResult;
        }
        int hour = (int) (time / 3600);
        int min = (int) ((time / 60) % 60);
        int sec = (int) (time % 60);
        if (hour > 0) {
            timeString.append(hour).append(" 小时");
        }
        if (min > 0) {
            timeString.append(min).append(" 分钟");
        }
        if (sec > 0) {
            timeString.append(sec).append(" 秒");
        }
    }

    private String currval;
    private String nextval;
    private StringBuilder timeString = new StringBuilder();

    public String getCurrval() {
        return currval;
    }

    public void setCurrval(String currval) {
        this.currval = currval;
    }

    public String getNextval() {
        return nextval;
    }

    public void setNextval(String nextval) {
        this.nextval = nextval;
    }

    public StringBuilder getTimeString() {
        return timeString;
    }

    public void setTimeString(StringBuilder timeString) {
        this.timeString = timeString;
    }

}
